home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
gui
/
imdialogs.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
6KB
|
141 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import wx
from gui.uberwidgets.UberCombo import UberCombo
from gui.uberwidgets.simplemenu import SimpleMenuItem
from gui.imwin import begin_conversation
from gui.toolbox import persist_window_pos
from gui.validators import LengthLimit
from wx import EXPAND, ALL, VERTICAL, HORIZONTAL, ALIGN_CENTER_VERTICAL, ALIGN_RIGHT, DEFAULT_DIALOG_STYLE, FRAME_FLOAT_ON_PARENT
from common import profile, pref
from util import oset
def ShowNewIMDialog():
NewIMDialog.MakeOrShow()
class NewIMDialog(wx.Dialog):
def __init__(self):
wx.Dialog.__init__(self, None, -1, _('New IM'), style = DEFAULT_DIALOG_STYLE | FRAME_FLOAT_ON_PARENT)
self.Name = 'New IM Dialog'
self.Sizer = wx.BoxSizer(VERTICAL)
p = wx.Panel(self, -1)
self.Sizer.Add(p, 1, EXPAND)
p.Sizer = wx.BoxSizer(VERTICAL)
s = wx.FlexGridSizer(2, 2)
s.AddGrowableCol(1, 1)
p.Sizer.Add(s, 1, EXPAND)
toctrl = self.toctrl = wx.TextCtrl(p, style = wx.TE_PROCESS_ENTER, validator = LengthLimit(255))
toctrl.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
fromcombo = self.fromcombo = UberCombo(p, None, skinkey = 'AppDefaults.PrefCombo')
fromcombo.SetItems(self.UpdateAccountItems(), 0)
Text = lambda t: wx.StaticText(p, -1, t)
s.Add(Text(_('To')), 0, ALIGN_RIGHT | ALIGN_CENTER_VERTICAL | ALL, 3)
s.Add(toctrl, 1, EXPAND | ALIGN_CENTER_VERTICAL | ALL, 3)
s.Add(Text(_('From')), 0, ALIGN_RIGHT | ALIGN_CENTER_VERTICAL | ALL, 3)
s.Add(fromcombo, 1, EXPAND | ALIGN_CENTER_VERTICAL | ALL, 3)
bs = wx.BoxSizer(HORIZONTAL)
sendbutton.Enable(False)
sendbutton.Bind(wx.EVT_BUTTON, self.OnAccept)
cancelbutton.Bind((wx.EVT_BUTTON,), (lambda e: self.Close()))
bs.Add(sendbutton, 0, ALL, 3)
bs.Add(cancelbutton, 0, ALL, 3)
p.Sizer.Add(bs, 0, ALIGN_RIGHT | ALL, 3)
self.Fit()
self.Size = wx.Size(300, self.Size.height)
profile.account_manager.connected_accounts.add_observer(self.WhenOnlineAcctsChange)
Bind = self.Bind
Bind(wx.EVT_CLOSE, self.OnClose)
Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
persist_window_pos(self, defaultrect = 'center')
def WhenOnlineAcctsChange(self, *a):
fromcombo = self.fromcombo
fromcombo.SetItems(self.UpdateAccountItems())
if fromcombo.Value not in fromcombo:
if len(fromcombo):
fromcombo.SetSelection(0)
else:
fromcombo.Value = _('No Connections')
self.UpdateButtonState()
def UpdateAccountItems(self):
if not hasattr(self, 'acctitems'):
self.acctitems = oset()
acctitems = self.acctitems
accounts = oset(profile.account_manager.connected_accounts)
accts = set((lambda .0: for item in .0:
item.id)(acctitems))
newaccts = accounts - accts
oldaccts = accts - accounts
for item in set(acctitems):
if item.id in oldaccts:
acctitems.remove(item)
continue
for account in newaccts:
if account.allow_contact_add:
acctitems.add(SimpleMenuItem([
account.serviceicon.Resized(16),
account.username], id = account))
continue
return list(acctitems)
def OnKeyDown(self, event):
ctrl = event.ControlDown()
key = event.GetKeyCode()
if ctrl and key == wx.WXK_DOWN:
self.fromcombo.SelectNextItem(True)
elif ctrl and key == wx.WXK_UP:
self.fromcombo.SelectPrevItem(True)
elif key == wx.WXK_ESCAPE:
self.Close()
elif key == wx.WXK_RETURN and bool(self.toctrl.Value) and len(self.fromcombo):
self.OnAccept()
else:
event.Skip()
self.UpdateButtonState()
def UpdateButtonState(self):
(wx.CallAfter,)((lambda : if bool(self.toctrl.Value):
passself.sendbutton.Enable(len(self.fromcombo))))
def OnAccept(self, event = None):
self.Hide()
proto = self.fromcombo.Value.id.connection
begin_conversation(proto.get_buddy(self.toctrl.Value))
self.Close()
def OnClose(self, event):
profile.account_manager.connected_accounts.remove_observer(self.WhenOnlineAcctsChange)
self.Show(False)
type(self).new_im_instance = None
self.Destroy()
def MakeOrShow(cls):
if not hasattr(cls, 'new_im_instance'):
cls.new_im_instance = None
if cls.new_im_instance:
cls.new_im_instance.Show(True)
cls.new_im_instance.Raise()
else:
cls.new_im_instance = NewIMDialog()
cls.new_im_instance.Show(True)
MakeOrShow = classmethod(MakeOrShow)